package com.tkjt.pms.calc.common;

import java.io.Serializable;

import lombok.Data;

@Data
public class CalcResult<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 成功标志
	 */
	private boolean success = true;
	/**
	 * 返回处理消息
	 */
	private String message = "操作成功！";
	/**
	 * 返回数据对象 data
	 */
	private T result;

	public CalcResult() {
		
	}
	
	public CalcResult<T> success(String message) {
		this.message = message;
		this.success = true;
		return this;
	}
	
	
	public void ok() {
		this.setSuccess(true);
		this.setMessage("成功");
	}
	
	
	public void ok(T data) {
		this.setSuccess(true);
		this.setMessage("成功");
		this.setResult(data);
	}
	
	public void error(String msg) {
		this.setMessage(msg);
		this.setSuccess(false);
	}
	
	public void error(String msg, T data) {
		this.setMessage(msg);
		this.setSuccess(false);
		this.setResult(data);
	}
	
}